Ooops, little bug with the cross product.
[andmenj-acm.git] / 10924 - Prime Words / 10924.cpp
blob7989914580e294ddc44863a0c744658e68945b4f
1 using namespace std;
2 #include <algorithm>
3 #include <iostream>
4 #include <iterator>
5 #include <sstream>
6 #include <fstream>
7 #include <cassert>
8 #include <climits>
9 #include <cstdlib>
10 #include <cstring>
11 #include <string>
12 #include <cstdio>
13 #include <vector>
14 #include <cmath>
15 #include <queue>
16 #include <deque>
17 #include <stack>
18 #include <list>
19 #include <map>
20 #include <set>
22 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
23 #define For(i, a, b) for (int i=(a); i<(b); ++i)
24 #define D(x) cout << #x " is " << x << endl
26 char buf[32];
28 bool p(int n){
29 for (int i=2; i*i<=n; ++i) if (n % i == 0) return false;
30 return true;
33 int main(){
34 while (fgets(buf, 32, stdin) != NULL){
35 int n = 0;
36 for (int i=0; i<strlen(buf)-1; ++i){
37 char c = buf[i];
38 n += (islower(c) ? c - 'a' + 1 : c - 'A' + 27);
40 printf("It is %sa prime word.\n", p(n) ? "" : "not ");
42 return 0;